package com.trkj.dao.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.YzrMedStock;

public interface IYzrMedStockDAO extends CrudRepository<YzrMedStock, String> {

	@Query("select max(yms.medStockId) from YzrMedStock yms where yms.medStockId like ?1%")
	public String findMaxId(String a);
	
	//判断库存是否存在
	@Query("select yms from YzrMedStock yms where yms.medStockMedId=?1 and yms.medStockBatchnumber=?2")
	public YzrMedStock findByMedicine(String medId, String batchNumber);
	
	//分组查询
	@Query("select yms from YzrMedStock yms")
	public List<YzrMedStock> findByGroup(Pageable pageable);
	
	//条件查询
	@Query("select yms from YzrMedStock yms where yms.medStockMedName like %?1% and yms.medStockStoreId=?2 order by yms.medStockId asc")
	public List<YzrMedStock> findByMedName(String medName,String cangku, Pageable pageable);
	
	//条件查询
	@Query("select yms from YzrMedStock yms where yms.medStockStoreId = ?1 order by yms.medStockId asc")
	public List<YzrMedStock> findByStore(String cangku,Pageable pageable);
}
